package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IPatrolCompletionForSuperView;
import com.cloudsigns.factorymanager2.engineering.model.IPatrolCompletionForSuperModel;
import com.cloudsigns.factorymanager2.engineering.model.PatrolCompletionForSuperModel;

/**
 * Created by tony on 2018/6/18.
 */

public class PatrolCompletionForSuperPresenter {
    private IPatrolCompletionForSuperView view;
    private IPatrolCompletionForSuperModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public PatrolCompletionForSuperPresenter(IPatrolCompletionForSuperView view) {
        this.view = view;
        this.model = new PatrolCompletionForSuperModel();
    }

    public void patrolCompletionForSuper() {


        model.patrolCompletionForSuper(view.getOrderId(),
                new PatrolCompletionForSuperModel.OnPatrolCompletionForSuperListener() {
                    @Override
                    public void patrolCompletionForSuperSunccessed() {
                        //需要在UI线程执行
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                view.patrolCompletionForSuperSuccess();
                                view.hideLoading();
                            }
                        });
                    }

                    @Override
                    public void patrolCompletionForSuperFailed(final String desc) {
                        //需要在UI线程执行
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                view.patrolCompletionForSuperFailed(desc);
                                view.hideLoading();
                            }
                        });
                    }
                });

    }
}
